<h2>DESCRIPTION</h2>

<em>r.sunmask</em> creates an output map layer based on an input elevation
raster map layer and the sun position. The output map layer contains the
cast shadow areas arising from sun shine and elevations. The user can define
the sun position either directly or the module calculates it from given
location and date/time parameters using the
<a href="http://rredc.nrel.gov/">NREL</a> sun position algorithm. So either
"A:"-parameters to specify the exact known sun position or "B:-parameters"
to specify date/time for sun position calculation by <em>r.sunmask</em> itself
have to be used.

<p>The module performs sunset/sunrise checks and refraction correction for sun
position calculation. Local coordinate systems are internally transformed to
latitude/longitude for the SOLPOS algorithm. The elevation is not considered
in the sunset/sunrise calculations.

<h2>NOTES</h2>

<em>r.sunmask</em> and daylight savings: Rather than converting the
local time to GMT, the SOLPOS algorithm uses what is called Local
Standard Time, which is generally politically defined as an offset
from GMT.  So the key is the offset from GMT, which the solpos Time
Zone parameter. If the user specifies clock time (different for
winter and summer), s/he would have to change the Time Zone
parameter seasonally in <em>r.sunmask</em> (timezone parameter). See also 
<a href="http://en.wikipedia.org/wiki/Daylight_saving_time_by_country">Daylight saving time by region and country</a>.

<p>
Note: In latitude/longitude locations the position coordinates pair
(east/west) has to be specified in decimal degree (not D:M:S). If
not specified, the map center's coordinates will be used.
Also <em>g.region -l</em> displays the map center's coordinates in
latitude/longitude (or <em>g.region -c</em> in the actual coordinate
system).

<p>
Note for module usage with the <em>-g</em> flag, when performing calculations
close to sunset/sunrise:

<div class="code"><pre>
 [...]
 sunangleabovehorizont=0.434240
 sunrise=07:59:19
 sunset=16:25:17
 Time (07:59:02) is before sunrise (07:59:19)!
 WARNING: Nothing to calculate. Please verify settings.
 No map calculation requested. Finished.
</pre></div>

In above calculation it appears to be a mistake as
the program indicates that we are before sunrise while
the <i>sun angle above horizon</i> is already positive.
The reason is that <i>sun angle above horizon</i> is
calculated with correction for atmosphere refraction while
<i>sunrise</i> and <i>sunset</i> are calculated <b>without</b>
correction for atmosphere refraction. The output without 
<em>-g</em> flag contains related indications.

<h2>EXAMPLE</H2>

Example for North Carolina sample data set for the calculation
of sun position angles and more:

<div class="code"><pre>
# set the region to a place near Raleigh (NC)
g.region raster=elev_lid792_1m -p

# compute only sun position and no output map
r.sunmask -s elev_lid792_1m year=2012 month=2 \
          day=22 hour=10 minute=30 timezone=-5
Using map center coordinates: 638650.000000 220375.000000
Calculating sun position... (using solpos (V. 11 April 2001) from NREL)
2012/02/22, daynum: 53, time: 10:30:00 (decimal time: 10.500000)
long: -78.678856, lat: 35.736160, timezone: -5.000000
Solar position: sun azimuth: 143.006409, sun angle above horz. (refraction corrected): 36.233879
Sunrise time (without refraction): 06:58:11
Sunset time  (without refraction): 17:58:47

# with -g flag, useful for eval() shell function
r.sunmask -s -g elev_lid792_1m  year=2012 month=2 \
          day=22 hour=10 minute=30 timezone=-5
Using map center coordinates: 638650.000000 220375.000000
Calculating sun position... (using solpos (V. 11 April 2001) from NREL)
date=2012/02/22
daynum=53
time=10:30:00
decimaltime=10.500000
longitudine=-78.678856
latitude=35.736160
timezone=-5.000000
sunazimuth=143.006409
sunangleabovehorizon=36.233879
sunrise=06:58:11
sunset=17:58:47
</pre></div>


<h2>Acknowledgements</h2>
Acknowledgements: National Renewable Energy Laboratory for their
<a href="http://rredc.nrel.gov/solar/codesandalgorithms/solpos/">SOLPOS 2.0</a> sun position
algorithm.

<h2>SEE ALSO</h2>
<em>
<a href="g.region.html">g.region</a>,
<a href="r.sun.html">r.sun</a>,
<a href="r.sunhours.html">r.sunhours</a>,
<a href="r.slope.aspect.html">r.slope.aspect</a>
</em>

<h2>AUTHOR</h2>
Janne Soimasuo, Finland 1994<br>
update to FP by Huidae Cho 2001<br>
added solpos algorithm feature by Markus Neteler 2001

<!--
<p>
<i>Last changed: $Date$</i>
-->
